import ast
import re

# 读取输入
# input_str = input().strip()
with open("Pratice\input.txt","r") as f:

    input_str = f.read()

# 正则表达式匹配模式
pattern = r'(\[.*?\]),"(\w+)"'

# 使用 re.match 进行匹配
match = re.match(pattern, input_str)

if match:
    # 获取匹配的列表和字符串部分
    nums = match.group(1)  # '[2,4,5,1]'
    color_str = match.group(2)  # 'RWWW'
    
    # 安全地解析为列表
    nums = ast.literal_eval(nums)

target = 0
ou_num = 0
ji_num = 0

for i in range(len(nums)):
    if color_str[i] != 'R':  
        if nums[i] % 2 == 1: 
            ji_num += 1
        else:  
            ou_num += 1
    elif nums[i] % 2:
        target = (target+1) %2

# 定义常量
MODE = int(1e9 + 7)
if target == 1 and ji_num <=0:
    print(0)
elif ji_num == 0 and ou_num == 0:
    print(0)
elif ji_num == 0:
    print(pow(2, ou_num, MODE))
else:
# 计算结果
    print(pow(2, ji_num + ou_num - 1, MODE))
